123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import { ConfigType } from "@/api/config";
- import Dialogs from "@/components/Dialog";
- // import AutoShowDialog from "@/dialog/auto";
- import Loading2 from "@/components/Loading2";
- import { routing } from "@/i18n/routing";
- import { server } from "@/utils/server";
- import "animate.css";
- import clsx from "clsx";
- import { Viewport } from "next";
- import { NextIntlClientProvider } from "next-intl";
- import { getMessages } from "next-intl/server";
- import { Inter as FontSans } from "next/font/google";
- import { notFound } from "next/navigation";
- import { ReactNode, Suspense } from "react";
- import "../editor.scss";
- import "../globals.scss";
- import { Providers } from "./providers";
- // 加载字体
- const fontSans = FontSans({
- subsets: ["latin"],
- variable: "--font-sans",
- });
- export const viewport: Viewport = {};
- interface Og {
- description: string;
- keywords: string;
- title: string;
- url: string;
- address: string;
- }
- interface System extends ConfigType {
- og: Og;
- }
- const getSystemReq = () => {
- return server.request<System>({
- url: "/v1/api/front/system/configs",
- method: "POST",
- });
- };
- export const generateMetadata = async () => {
- const { data } = await getSystemReq();
- return {
- title: {
- template: "%s | 8G.game",
- default: "8G.game",
- },
- keywords: ["8G.game"],
- description: "The home of over 30 million players",
- appleWebApp: {
- statusBarStyle: "black",
- },
- formatDetection: {
- email: false,
- address: false,
- telephone: false,
- },
- referrer: "no-referrer",
- other: {
- viewport: [
- "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0," +
- " viewport-fit=cover ",
- ],
- },
- openGraph: {
- title: data?.og?.title,
- description: data?.og?.description,
- image: data?.og?.url,
- url: data?.og?.address,
- },
- twitter: {
- card: data?.og?.address,
- title: data?.og?.title,
- description: data?.og?.description,
- image: data?.og?.url,
- },
- };
- };
- export default async function LocaleLayout({
- children,
- params: { locale },
- }: {
- children: ReactNode;
- params: { locale: string };
- }) {
- if (!routing.locales.includes(locale as any)) {
- notFound();
- }
- const messages = await getMessages();
- return (
- <html lang={locale} suppressHydrationWarning data-renterid={process.env.RENTER_ID}>
- <head>
- <script defer={true} src={"/iconfont.js"} />
- </head>
- <body className={clsx("font-sans", fontSans.variable)}>
- <NextIntlClientProvider messages={messages}>
- <Providers themeProps={{ attribute: "class" }}>
- {children}
- <Suspense>
- <Dialogs></Dialogs>
- </Suspense>
- </Providers>
- </NextIntlClientProvider>
- <div
- id="globalMask"
- style={{
- position: "fixed",
- zIndex: 100,
- background: "rgba(0,0,0,.8)",
- display: "none",
- left: 0,
- top: 0,
- right: 0,
- bottom: 0,
- alignItems: "center",
- justifyContent: "center",
- }}
- >
- <Loading2 width={10}></Loading2>
- </div>
- </body>
- </html>
- );
- }
|